package com.fbinggun.fbinggunutil.gui;

import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryHolder;

import java.util.HashMap;
import java.util.Map;

/**
 * 菜单的Holder 在打开菜单时 new FHolder() 来获取Inventory
 */
public class FHolder implements InventoryHolder {
    Gui gui;
    Map<Integer, SlotItem> temp = new HashMap<>();
    int page = 1;
    Player player;

    public FHolder(Gui gui) {
        this.gui = gui;
    }

    public FHolder(Gui gui, int page) {
        this.gui = gui;
        this.page = page;
    }

    public FHolder(Gui gui, int page, Player player) {
        this.gui = gui;
        this.page = page;
        this.player = player;
    }

    public FHolder(Gui gui, Player player) {
        this.gui = gui;
        this.player = player;
    }

    public Map<Integer, SlotItem> getTemp() {
        return temp;
    }

    public void putTemp(int slot, SlotItem slotItem) {
        temp.put(slot, slotItem);

    }

    public SlotItem getTempMap(int slot) {
        return temp.get(slot);
    }

    public Gui getGui() {
        return gui;
    }

    @Override
    public Inventory getInventory() {
        return Bukkit.createInventory(this, gui.getSize(), gui.getTitle(player));
    }

    public int getPage() {
        return page;
    }

}
